//
//  HENurseOrgCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/25.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HENurseOrgCell.h"

@interface HENurseOrgCell ()

@property (nonatomic, strong) UIImageView *orgImgView;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *descLb;
@property (nonatomic, strong) UILabel *addressLb;
@end

@implementation HENurseOrgCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.qmui_borderPosition = QMUIViewBorderPositionTop;
        self.qmui_borderWidth = 0.5;
        self.qmui_borderColor = CSplitLineColor;
     
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    self.contentView.backgroundColor = CLightGrayColor;
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
 
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(0);
        make.left.equalTo(self.contentView).mas_offset(0);
        make.right.equalTo(self.contentView).mas_offset(0);
        make.height.mas_greaterThanOrEqualTo(125);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
    
    // 商品图片
    _orgImgView = [UIImageView new];
    _orgImgView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:_orgImgView];
    
 
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYBlodFont(18);
    _titleLb.numberOfLines = 0;
    [warp addSubview:_titleLb];
    
    _descLb = [UILabel new];
    _descLb.text = @"-";
    _descLb.font = DYFont(15);
    _descLb.numberOfLines = 2;
    _descLb.textColor = CNavLightBlackColor;
    [warp addSubview:_descLb];
    
    _addressLb = [UILabel new];
    _addressLb.text = @"-";
    _addressLb.font = DYFont(15);
    _addressLb.numberOfLines = 0;
    _addressLb.textColor = CNavLightBlackColor;
    [warp addSubview:_addressLb];
    
    [_orgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(warp);
        make.left.equalTo(warp).offset(15);
        make.width.height.offset(100);
    }];
    [_orgImgView hg_setAllCornerWithCornerRadius: 8];

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(-11);
    }];
    
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(-11);
    }];
    
    [_addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_descLb.mas_bottom).offset(15);
        make.left.equalTo(_orgImgView.mas_right).mas_offset(11);
        make.right.equalTo(warp).mas_offset(11);
        make.bottom.equalTo(warp).mas_offset(-10);
    }];
 
}

- (void)setModel:(HEOrgModel *)model {
    _model = model;
    
    [_orgImgView sd_setImageWithURL:[NSURL URLWithString: model.org_icon] placeholderImage:IMAGE_NAMED(@"noImage")];
    _titleLb.text = model.org_name;
    _descLb.text = model.org_brief;
    _addressLb.text = model.org_address;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
